/*
 * JDerroresPlanilla.java
 *
 * Created on 12 de junio de 2008, 04:09 PM
 */

package pantalla;
import utiles.*;
import javax.swing.*;
import javax.swing.table.*;
import java.io.*;    
import java.util.*;
import CtaCorr.*;
import java.rmi.*;
import java.util.ArrayList;
/**
 *
 * @author  Renato Castillo
 */
public class JDerroresPlanilla extends javax.swing.JDialog {
    String identificador;
    /** Creates new form JDerroresPlanilla */
    public JDerroresPlanilla(java.awt.Frame parent, boolean modal,String id) {
        super(parent, modal);
        super.setTitle("Errores de la Planilla");
        initComponents();
        int cosaux;
        
        identificador=id;
      
        ArrayList araux1=ConsultasCliRmi.consulta("SELECT DNI, nombre_tra as Trabajador, nom_error as Descripcion, cod_error [Cod.Error]," +
                " procedimiento, error, linea_codigo, ano, mes, desc_tipo_planilla as [Tipo Planilla], neto_pagar as [Neto a Pagar] "+
                " FROM         errores_planilla",identificador);
        cosaux=araux1.size()-2;
        if(cosaux<1){
            this.dispose();
        }else{
            jtErrores.setModel(ConsultasCliRmi.llenatabla("SELECT DNI, nombre_tra as Trabajador, nom_error as Descripcion, cod_error [Cod.Error]," +
                " procedimiento, error, linea_codigo, ano, mes, desc_tipo_planilla as [Tipo Planilla], neto_pagar as [Neto a Pagar] "+
                " FROM         errores_planilla",identificador));
            this.pack();
            this.setLocationRelativeTo(null);
            this.setVisible(true);
        }
        
                
    }
    
    
    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jScrollPane1 = new javax.swing.JScrollPane();
        jtErrores = new javax.swing.JTable();
        jbCerrar = new javax.swing.JButton();
        jbImprimir = new javax.swing.JButton();

        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);

        jtErrores.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null}
            },
            new String [] {
                "Title 1", "Title 2", "Title 3", "Title 4"
            }
        ));
        jScrollPane1.setViewportView(jtErrores);

        jbCerrar.setFont(new java.awt.Font("Arial", 1, 12));
        jbCerrar.setIcon(new javax.swing.ImageIcon(getClass().getResource("/org/fife/plaf/Office2003/close.gif"))); // NOI18N
        jbCerrar.setText("Cerrar");
        jbCerrar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jbCerrarActionPerformed(evt);
            }
        });

        jbImprimir.setFont(new java.awt.Font("Arial", 1, 12)); // NOI18N
        jbImprimir.setIcon(new javax.swing.ImageIcon(getClass().getResource("/org/fife/plaf/Office2003/print.gif"))); // NOI18N
        jbImprimir.setText("Imprimir");
        jbImprimir.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jbImprimirActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 827, Short.MAX_VALUE)
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                        .addComponent(jbImprimir)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(jbCerrar)))
                .addContainerGap())
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 206, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jbCerrar)
                    .addComponent(jbImprimir))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void jbCerrarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jbCerrarActionPerformed
        int res = javax.swing.JOptionPane.showConfirmDialog( this,"Esta seguro de cerrar la ventana de errores?",
                "Confirmar",javax.swing.JOptionPane.YES_NO_OPTION );
        if(res==javax.swing.JOptionPane.YES_OPTION){
            this.dispose();
        }
    }//GEN-LAST:event_jbCerrarActionPerformed

private void jbImprimirActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jbImprimirActionPerformed
// TODO add your handling code here:
    try{
        this.jtErrores.print();        
    }catch(Exception e ){
        javax.swing.JOptionPane.showMessageDialog(this, "Error al imprimir la tabla " + e.getMessage(),
                "Error al Imprimir", JOptionPane.ERROR_MESSAGE );        
    }
}//GEN-LAST:event_jbImprimirActionPerformed
    
    /**
     * @param args the command line arguments
     */
    
    
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JButton jbCerrar;
    private javax.swing.JButton jbImprimir;
    private javax.swing.JTable jtErrores;
    // End of variables declaration//GEN-END:variables
    
}
